package com.liuyuan.service.impl;

import com.liuyuan.mapper.NewsDao;
import com.liuyuan.pojo.News;
import com.liuyuan.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements NewsService {
    @Autowired
    private NewsDao newsDao;
    @Override
    public News getNewsById(int id) {

//      News news=new News();
//      news.setId(id);
//      news.setTitle("zhongyuangongxueyuan");
//      news.setAuthor("yangyuqi");
//        System.out.println(news.getId());
//        System.out.println(news.getTitle());
//        System.out.println(news.getAuthor());
        return newsDao.getNewsById(id);
    }
    @Override
    public List<News> getAllNews() {
        return newsDao.getAllNews();
    }

    @Override
    public int insertNews(News news) {
        int insertNews = newsDao.insertNews(news);
        int addNews = newsDao.addNews(news);
        return addNews;
    }

    @Override
    public int updateNews(News news) {
        return newsDao.updateNews(news);
    }

    @Override
    public int deleteNews(int id) {
        return newsDao.deleteNews(id);
    }
}
